/// Trait for host functions
pub trait HostFunctions: Send + Sync {}

/// Function type for validating certificate chains, the parameter is certificate bytes, returns true if the certificate is valid
pub type ValidateCertChainFn = fn(&[u8]) -> bool;

/// Function type for getting unmatched measurements, the parameters are measured values, reference file ids and attester_type, returns unmatched measurements
pub type GetUnmatchedMeasurementsFn = fn(&Vec<String>, &Vec<String>, &str) -> Vec<String>;

/// Function type for querying configuration, the parameter is configuration key, returns configuration value
pub type QueryConfigerationFn = fn(String) -> String;

/// Service host functions
pub struct ServiceHostFunctions {
    pub validate_cert_chain: ValidateCertChainFn,
    pub get_unmatched_measurements: GetUnmatchedMeasurementsFn,
    pub query_configeration: QueryConfigerationFn,
} 

impl HostFunctions for ServiceHostFunctions {}

impl ServiceHostFunctions {
    /// Create a new instance of ServiceHostFunctions
    pub fn new(validate_cert_chain: ValidateCertChainFn, get_unmatched_measurements: GetUnmatchedMeasurementsFn, query_configeration: QueryConfigerationFn) -> Self {
        Self {
            validate_cert_chain,
            get_unmatched_measurements,
            query_configeration,
        }
    }
}

/// Agent host functions
pub struct AgentHostFunctions {
    pub query_configeration: QueryConfigerationFn,
}

impl HostFunctions for AgentHostFunctions {}

impl AgentHostFunctions {
    /// Create a new instance of AgentHostFunctions
    pub fn new(query_configeration: QueryConfigerationFn) -> Self {
        Self {
            query_configeration,
        }
    }
}